package com.resto.scm.web.manager;


import com.resto.common.dao.BaseDao;
import com.resto.common.dao.domain.BaseQuery;
import com.resto.common.dao.domain.UpdateByQuery;
import com.resto.common.dao.helper.DaoHelper;
import com.resto.common.dao.manager.BaseManager;
import com.resto.scm.web.dao.DocStkInPlanHeaderDao;
import com.resto.scm.web.dto.DocStkInPlanHeaderDetailDo;
import com.resto.scm.web.dto.DocStkInPlanHeaderDo;
import com.resto.scm.web.model.DocStkInPlanHeader;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

@Component("docStkInPlanHeaderManager")
public class DocStkInPlanHeaderManager extends BaseManager<DocStkInPlanHeader> {
    @Resource
    private DocStkInPlanHeaderDao docStkInPlanHeaderDao;


    @Override
    public BaseDao<DocStkInPlanHeader> getDao() {
        return this.docStkInPlanHeaderDao;
    }

    public static void main(String[] args) {
       DaoHelper.genXMLWithFeature("E:\\temp\\mapper\\DocStkInPlanHeaderDao.xml",
               DocStkInPlanHeaderDao.class, DocStkInPlanHeader.class, "doc_stk_in_plan_header",false);
    }

    public List<DocStkInPlanHeaderDetailDo> queryJoin4Page(String shopDetailId) {

          return docStkInPlanHeaderDao.queryJoin4Page(shopDetailId);
    }

    public void updateDocStkStatusById(Long id, String orderStatus) {
        BaseQuery<DocStkInPlanHeader> query = BaseQuery.getInstance(new DocStkInPlanHeader());
        query.getData().setId(id);
        DocStkInPlanHeader updateDo = new DocStkInPlanHeader();
        updateDo.setOrderStatus(orderStatus);
        UpdateByQuery<DocStkInPlanHeader> updateByQuery = new UpdateByQuery<>(query,updateDo);
        docStkInPlanHeaderDao.updateByQuery(updateByQuery);
    }
}
